package com.wuliupai.delivery.wuliupaidelivery.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wuliupai.delivery.wuliupaidelivery.App;
import com.wuliupai.delivery.wuliupaidelivery.R;

/**
 * 首页抽屉 个人中心
 */

public class HomeLeftMenuAdapter extends BaseAdapter {

    private final String[] mPersonalCenteritemTitle;
    private final int[] mMPersonalCenteritemicon;
    private Context context;

    public HomeLeftMenuAdapter(Context context) {
        this.context = context;
        mPersonalCenteritemTitle = new String[]{"任务记录", "派哥钱包", "计算运费", "任务统计",
                "修改密码", "系统消息", "退出登录"};
        mMPersonalCenteritemicon = new int[]{
                R.mipmap.my_icon_order, R.mipmap.my_icon_wallet, R.mipmap.my_calculate,
                R.mipmap.my_icon_mission, R.mipmap.my_icon_calculate, R.mipmap.my_icon_message,
                R.mipmap.my_icon_uot};
    }

    @Override
    public int getCount() {
        return mPersonalCenteritemTitle.length;
    }

    @Override
    public Object getItem(int position) {
        return mPersonalCenteritemTitle[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHoldePersonalCenter holder;
        if (convertView == null) {
            holder = new ViewHoldePersonalCenter();
            convertView = View.inflate(context, R.layout.item_personal_center, null);
            holder.iv_personal_center_icon = (ImageView) convertView.findViewById(R.id.iv_personal_center_icon);
            holder.tv_personal_center_title = (TextView) convertView.findViewById(R.id.tv_personal_center_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHoldePersonalCenter) convertView.getTag();
        }
        holder.tv_personal_center_title.setText(mPersonalCenteritemTitle[position]);
        holder.iv_personal_center_icon.setImageResource(mMPersonalCenteritemicon[position]);
        return convertView;
    }

    class ViewHoldePersonalCenter {
        ImageView iv_personal_center_icon;
        TextView tv_personal_center_title;
    }
}
